package tool;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import pojo.Backenduser;
import pojo.Devuser;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class PerHandle extends HandlerInterceptorAdapter {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        HttpSession session=request.getSession();
        Devuser devuser=(Devuser) session.getAttribute("devuser");
        Backenduser backenduser=(Backenduser) session.getAttribute("user");
        if(null!=devuser){
            return true;
        }else  if(null!=backenduser){
            return  true;
        }
        else {
            response.sendRedirect(request.getContextPath()+"/403.jsp");
            return false;
        }
    }

}
